import { NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';

export async function PUT(
  request: Request,
  { params }: { params: { openId: string } }
) {
  try {
    const { openId } = params;
    const data = await request.json();

    // 更新用户信息
    const updatedUser = await prisma.user.update({
      where: {
        openId: openId
      },
      data: {
        uName: data.uName,
        college: data.college,
        gender: data.gender,
        birth: data.birth
      }
    });

    return NextResponse.json(updatedUser, { status: 200 });
  } catch (error) {
    console.error('更新用户信息失败:', error);
    return NextResponse.json(
      { error: '更新用户信息失败' },
      { status: 500 }
    );
  }
}